<?php
session_start();
if(session_is_registered($_GET["user_id"])){}
else 
die("<a href='../../index.php'>PLEASE LOGIN AGAIN... </a>");

include("../../connect.php");

$id   = $_REQUEST["id"];
//echo "the id is: ".$id;
$type = $_REQUEST["type"];
$user = $_GET["user_id"];

if ($type == "folder") {
	$query = "delete from articles where id_article = $id or id_parent = $id";
	$res = mysql_query($query);
}else 
if ($type == "file"){
	$query = "delete from articles where id_article = $id ";
	$res = mysql_query($query);
}
	if($res)
		echo "<script> window.location='../files.php?user_id=$user' </script>";
/*
Fix these bugs:  ###########################
- add last level property to the folder db.. 
- fix the delete file from the disk
*/

?>